Linq order by aggregate in the select { }

Posted by Joe Pitz on Stack Overflow See other posts from Stack Overflow or by Joe Pitz
Published on 2010-03-31T20:28:16Z Indexed on 2010/03/31 20:43 UTC
Read the original article Hit count: 217

Filed under:
|

Here is one I am working on:

var fStep =
            from insp in sq.Inspections
            where insp.TestTimeStamp > dStartTime && insp.TestTimeStamp < dEndTime
                && insp.Model == "EP" && insp.TestResults != "P"
            group insp by new { insp.TestResults, insp.FailStep } into grp

            select new
            {
                FailedCount = (grp.Key.TestResults == "F" ? grp.Count() : 0),
                CancelCount = (grp.Key.TestResults == "C" ? grp.Count() : 0),
                grp.Key.TestResults,
                grp.Key.FailStep,
                PercentFailed = Convert.ToDecimal(1.0 * grp.Count() /tcount*100)

            } ;

I would like to orderby one or more of the fields in the select projection.

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about c#